package com.CityHunter.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.CityHunter.R;

public class MenuGridViewAdapter extends BaseAdapter{
	
	private Context mContext;
	private String[] items;
	private int[] icons;
	
	public MenuGridViewAdapter(Context mContext,String[] titles,int[] icons){
		this.mContext = mContext;
		this.items = titles;
		this.icons = icons;
	}
	
	@Override
	public int getCount(){
		return items.length;
	}
	
	@Override
	public Object getItem(int position){
		return items[position];
	}
	
	@Override
	public long getItemId(int position){
		return position;
	}
	
	@Override
	public View getView(int position,View convertView,ViewGroup parent){
		
		LayoutInflater factory = LayoutInflater.from(mContext);
		View v = (View)factory.inflate(R.layout.menu_grid_view, null);
		ImageView iv = (ImageView)v.findViewById(R.id.menuIcon);
		TextView tv = (TextView)v.findViewById(R.id.menuTitle);
		// Set the Image and text to display
		iv.setImageResource(icons[position]);
		tv.setText(items[position]);
		
		return v;
	}
	
}
